/*    */ package handling.login.handler;
/*    */ 
/*    */ import com.alibaba.druid.pool.DruidPooledConnection;
/*    */ import database.DatabaseConnection;
/*    */ import java.sql.PreparedStatement;
/*    */ import java.sql.SQLException;
/*    */ import java.util.ArrayList;
/*    */ import java.util.List;
/*    */ import org.apache.logging.log4j.LogManager;
/*    */ import org.apache.logging.log4j.Logger;
/*    */ import tools.data.input.LittleEndianAccessor;
/*    */ 
/*    */ 
/*    */ public class UpdatePlayerSlots
/*    */ {
/* 16 */   private static final Logger log = LogManager.getLogger();
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public static void handlePacket(LittleEndianAccessor lea) {
/* 23 */     lea.readInt();
/* 24 */     lea.skip(1);
/* 25 */     int size = lea.readInt();
/* 26 */     List<Integer> playerID = new ArrayList<>();
/* 27 */     for (int i = 0; i < size; i++) {
/* 28 */       playerID.add(Integer.valueOf(lea.readInt()));
/*    */     }
/*    */     
/* 31 */     try(DruidPooledConnection con = DatabaseConnection.getInstance().getConnection(); 
/* 32 */         PreparedStatement ps = con.prepareStatement("UPDATE characters SET position = ? WHERE id = ?")) {
/* 33 */       for (int j = 0; j < playerID.size(); j++) {
/* 34 */         ps.setInt(1, j);
/* 35 */         ps.setInt(2, ((Integer)playerID.get(j)).intValue());
/* 36 */         ps.executeUpdate();
/*    */       }
/*    */     
/* 39 */     } catch (SQLException e) {
/* 40 */       log.error("变更角色位置出错", e);
/*    */     } 
/*    */   }
/*    */ }


/* Location:              C:\PGX\Server.jar!\handling\login\handler\UpdatePlayerSlots.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */